libxl/devd: correctly manipulate the dguest list
authorRoger Pau Monne <roger.pau@citrix.com>
Tue, 16 May 2017 07:59:24 +0000 (08:59 +0100)
committerWei Liu <wei.liu2@citrix.com>
Fri, 19 May 2017 13:34:01 +0000 (14:34 +0100)
commit536ec5f13c066f10b5e8851392e622cc99f969f7
tree60743da77460aecd51b606ef02b6d5d9d3eb3075
parentfd519a51192b97168ab1a9ca3405d75d89341ee2
libxl/devd: correctly manipulate the dguest list

Current code in backend_watch_callback has two issues when manipulating the
dguest list:

1. backend_watch_callback forgets to remove a libxl__ddomain_guest from the
list of tracked domains when the related data is freed, causing dereferences
later on when the list is traversed. Make sure that a domain is always removed
from the list when freed.

2. A spurious device state change can cause a dguest to be freed, with active
devices and without being removed from the list. Fix this by always checking if
a dguest has active devices before freeing and removing it.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reported-by: Reinis Martinsons <admin@frp.lv>
Suggested-by: Ian Jackson <ian.jackson@eu.citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Release-acked-by: Julien Grall <julien.grall@arm.com>
tools/libxl/libxl_device.c